#!/usr/bin/python
# -*- coding: UTF-8 -*-

class Conllection(object):

    def testDisc(self):
        self.__person={
            "name":"张学友",
            "age":56,
            "love":"singsong"
                }
        self.__person["address"]="hongkong"
        print self.__person
        # {'age': 56, 'love': 'singsong', 'name': '\xe5\xbc\xa0\xe5\xad\xa6\xe5\x8f\x8b', 'address': 'hongkong'}


    def getVal(self):
        if "wife" in self.__person:
            print "张学友有老婆了"
        print self.__person.get("wife") #None
        # print self.__person["wife"]
        # KeyError: 'wife'

    def delVal(self):
        if "wife" in self.__person:
            self.__person.pop("wife") #KeyError: 'wife'

    def list2Map(self):
        print dict(zip(["name","age"],["zhangsan",18]))
        #{'age': 18, 'name': 'zhangsan'}

    def eachDict(self):
        for x in self.__person:
            print x
            #age; love; name; address
        for v in self.__person.values():
            print v
            #56; singsong; 张学友; hongkong
        for k,v in self.__person.items():
            print k,"---",v
            # age - -- 56
            # love - -- singsong
            # name - -- 张学友
            # address - -- hongkong
if __name__ == '__main__':
    conllection = Conllection()
    conllection.testDisc()
    # conllection.getVal()
    # conllection.delVal()
    # conllection.list2Map()
    conllection.eachDict()
